<template>
	<view class="mainpadding">
		<view class="ffffff radius mainpadding flexbetween" @click="show=true">
			<view class="ershiba zhonghei fonweight">退款类型</view>
			<u-radio-group v-model="type" placement="row" circle>
				<u-radio activeColor="#ff8505" :customStyle="{marginRight: '30rpx'}" label="我要退款(无需退货)"
					name="0"></u-radio>
					<u-radio activeColor="#ff8505" label="退货退款"
						name="1"></u-radio>
			</u-radio-group>
		</view>
		<view class="ffffff radius mainpadding margin_top flexbetween" @click="show=true">
			<view class="ershiba zhonghei fonweight">申请原因</view>
			<view class="flexright">
				<view class="ershil xiaohui margin_right1">{{reason?reason:'请选择申请原因'}}</view>
				<u-icon name="arrow-right" color="#999999"></u-icon>
			</view>
		</view>
		<view class="ffffff radius mainpadding flexbetween margin_top">
			<view class="ershiba zhonghei fonweight">退款金额</view>
			<view class="ershiba xiaocheng fonweight">￥{{dataAll.price}}</view>
		</view>
		<view class="ffffff radius mainpadding margin_top">
			<view class="ershiba zhonghei fonweight">申请说明</view>
			<textarea class="textarea margin_top" placeholder="请您详细填写申请说明" v-model="refund_content"></textarea>
		</view>
		<u-picker :show="show" :columns="columns" keyName="name" @cancel="show=false" @confirm="confirm"></u-picker>
		<view class="gudingdb mainpadding">
			<view class="bigbtn" @click="submit">提交申请</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				show:false,
				columns:[],
				order_id:"",
				order_goods_id:"",
				type:"0",
				reason:"",
				refund_content:"",
				dataAll:""
			}
		},
		onLoad(options) {
			this.order_id = options.order_id
			this.order_goods_id = options.order_goods_id
			this.orderTklx()//退款理由
			this.getRefundPriceData()//退款金额
		},
		methods: {
			submit(){
				if(this.reason==""){
					httpRequest.toast("请选择退款原因")
					return false
				}
				if(this.refund_content==""){
					httpRequest.toast("请输入申请说明")
					return false
				}
				httpRequest.request('/api/order/addApply', 'POST', {
					order_id:this.order_id,
					order_goods_id:this.order_goods_id,
					type:this.type,
					reason:this.reason,
					refund_content:this.refund_content,
				}).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				})
			},
			confirm(e){
				this.reason = e.value[0].name
				this.show=false
			},
			orderTklx(){//退款理由
				httpRequest.request('/api/order/orderTklx', 'GET', {
				}).then(res => {
					this.columns.push(res.data)
				})
			},
			getRefundPriceData(){//退款金额
				httpRequest.request('/api/order/getRefundPriceData', 'GET', {
					order_id:this.order_id,
					order_goods_id:this.order_goods_id,
				}).then(res => {
					
					this.dataAll = res.data
				})
			},
			
		}
	}
</script>

<style lang="scss" scoped>
.textarea{
	height: 100rpx;
}
</style>
